import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import MyHome from "../views/MyHome.vue";
import Center from '../views/MyCenter.vue';
import MyCourse from "../views/MyCourse.vue";
import CourseDetail from '../components/CourseDetail.vue';
import CourseWare from '../components/CourseWare.vue';
import ExamList from '../components/ExamList.vue';
import MyNews from "../views/MyNews.vue";
import MyLogin from "../views/MyLogin.vue";
import MyRegister from "../views/MyRegister.vue";
import NoticeList from '../components/NoticeList.vue';
import TestList from '../components/TestList.vue';
import HouseWork from '../components/HouseWork.vue';
import UserInfo from '../components/UserInfo.vue';
import NoticeDetail from '../components/NoticeDetail.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/login'
   },
  {
    path: '/home',
    name: 'home',
    component: MyHome
  },
  // 课程列表
  {
    path: '/course',
    name: 'course',
    component: MyCourse
  },
  // 课程详情
  {
    path: '/courseDetail',
    name: 'courseDetail',
    component: CourseDetail,
    
     // 嵌套路由不加/
     children: [
      { 
        path: "courseWare",
       component: CourseWare,
       props: route => ({param: route.query.param}),
      },
      { 
        path: "exam", 
        component: ExamList 
      }
    ] 

  },
  {
    path: '/news',
    name: 'news',
    component: MyNews
  },
  // 个人中心
  {
    path: '/center',
    name: 'center',
    component: () => import(/* webpackChunkName: "about" */ '../views/MyCenter.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: MyLogin
  },
  {
    path: '/register',
    name: 'register',
    component: MyRegister
  },
  // 个人信息
  {
    path:'/userInfo',
    name:'userInfo',
    component:UserInfo, 
    props: route => ({param: route.query.param})
  },
  // 首页
  // 通知
  {
    path: '/notice',
    name: 'notice',
    component: NoticeList,
    
  },
  // 通知详情
  {
    path: '/noticeDetail',
    name: 'noticeDetail',
    component: NoticeDetail,
    props: route => ({param: route.query.param})
  },
 
  // 考试列表
  {
    path: '/exam',
    name: 'exam',
    component: ExamList
  },
  // 作业列表
  {
    path: '/housework',
    name: 'housework',
    component: HouseWork
  },

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
